// mypage/checkCard/checkCard.js



Page({
  /*页面的初始数据*/
  data: {
    type: '',
    cards: [
      {img: '/images/icon25.png',name:'微信支付',checked:false},
      {img: '/images/icon71.png',name:'中国农业银行(4071)',checked:false},
      {img: '/images/icon72.png',name:'中国工商银行(4071)',checked:false},
      {img: '/images/icon80.png',name:'中国建设银行(4071)',checked:false}
    ],
    cur_index: null
  },
  /*生命周期函数--监听页面加载*/
  onLoad: function (options) {
    var that = this;
    if(options.type){
      that.setData({type: options.type})
      if(options.type==2){
        wx.setNavigationBarTitle({title: '充值方式',})
      }
    }
  },
  check_card:function(e){
    var that=this,cards=that.data.cards;
    var index=e.currentTarget.dataset.index;
    cards.forEach((item,i)=>{
      cards[i].checked=false;
      cards[index].checked=true;
    })
    that.setData({cards:cards,cur_index:index})
  },
  nav_add:function(){
    wx.redirectTo({
      url: '../addBankcard/addBankcard',
    })
  },
  confirm_card:function(){
    var that=this,cur_index=that.data.cur_index;
    if(cur_index != null){
      
    }
  },
})